//
//  WSEmoticons.swift
//  emoticonView
//
//  Created by 武莎莎 on 15/9/15.
//  Copyright © 2015年 itcast. All rights reserved.
//

import UIKit

class WSEmoticons: NSObject {

    // 表情文字
    var chs: String?
    // 表情图片
    var png: String?
    // 表情图片的完整路径
    var imagePath:String {
        return png != nil ? NSBundle.mainBundle().bundlePath + "/Emoticons.bundle/" + png! : ""
    }
    // emoji编码
    var code: String? {
        didSet {
            // 获取16进制的数值
            let scanner = NSScanner(string: code!)
            
            var value: UInt32 = 0
            scanner.scanHexInt(&value)
            emoji = String(Character(UnicodeScalar(value)))
        }
    }
    // emoji字符串
    var emoji: String?
    // 删除按钮的标记
    var isRemove:Bool = false
    // 是否为空按钮的标记
    var isEmpty:Bool = false
    
    init(isEmpty:Bool) {
        super.init()
        self.isEmpty = isEmpty
    }
    
    init(isRemove:Bool) {
        super.init()
        
        self.isRemove = isRemove
    }
    // 字典转模型
    init(dict:[String:String]) {
        super.init()
        setValuesForKeysWithDictionary(dict)
    }
    
    override func setValue(value: AnyObject?, forUndefinedKey key: String) {}
    
    override var description:String {
        let keys = ["chs","png","code"]
        return dictionaryWithValuesForKeys(keys).description
    }
}
